import React from 'react';


// 导入子组件
import CmtAdd from './CmtAdd'

import CmtItem from './CmtItem';
import { thisExpression } from '@babel/types';


class Comments extends React.Component {

  constructor(props) {
    // 必须通过super调用父类的构造器方法
    super(props);
  }

  componentWillMount(){
    this.props.get_comments_async();
  }

  render() {
    const comments=this.props.comments;
    return (
      <div className="container">
        <h1>评论管理</h1>
        <hr />
        <CmtAdd {...this.props}></CmtAdd>
        <hr />
        <ul className="list-group">
          {comments.map((item, index) => (
            <CmtItem key={index} {...item} {...this.props}></CmtItem>
          ))}
        </ul>

      </div>
    );
  }
}

export default Comments;
